var http=require('http');
var querystring=require('querystring');

var postData=querystring.stringify({
  'thread_id':'6336761722442875649',
'parent_id':'',
'nonce':'581e2fba5efea',
'message':'node 测试',
'author_name':'nickname',
'author_email':'76935363@qq.com',
'v':'16.6.16',
})

var options={
  hostname:'suiyueranb.duoshuo.com',
  port:80,
  path:'/api/posts/create.json',
  method:'POST',
  headers:{
    'Accept':'*/*',
'Accept-Encoding':'gzip, deflate',
'Accept-Language':'zh-CN,zh;q=0.8',
'Connection':'keep-alive',
'Content-Length':postData.length,
'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8',
'Cookie':'duoshuo_unique=47a5c9f9f5be619a',
'Host':'suiyueranb.duoshuo.com',
'Origin':'http://blog.muzishg.com',
'Referer':'http://blog.muzishg.com/index/article/id/8',
'User-Agent':'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.80 Safari/537.36 Core/1.47.516.400 QQBrowser/9.4.8113.400',
  }
}

var req=http.request(options,function(res){
  console.log('Status:'+res.statusCode);
  console.log('headers:'+JSON.stringify(res.headers));

  res.on('data',function(chunk){
    console.log(Buffer.isBuffer(chunk));
    console.log(typeof chunk);
  })

  res.on("end",function(){
    console.log('评论完毕');
  })

})

req.on('error',function(e){
    console.log('Error:'+e.message);
})

req.write(postData);

req.end();

// Accept:application/json, text/javascript, */*; q=0.01
// Accept-Encoding:gzip, deflate
// Accept-Language:zh-CN,zh;q=0.8
// Connection:keep-alive
// Content-Length:81
// Content-Type:application/x-www-form-urlencoded; charset=UTF-8
// Cookie:imooc_uuid=5cfe3711-043f-4c97-a121-1d4a027db83e; imooc_isnew_ct=1478508406; loginstate=1; apsid=FkZjNkYzc4MDNhYzAyZGNiNDIwMWQxNWJjYThjYjEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMTI0OTkxNgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA3NjkzNTYzNTNAcXEuY29tAAAAAAAAAAAAAAAAAAAAADBiNGU2NmI3ZGQ0NDE1NDhhYWFjOGM4ZWYwZDdiNWJlhj8gWIY%2FIFg%3DYj; last_login_username=769356353%40qq.com; PHPSESSID=1ll78nniu81l4qq9no25hcu7q2; IMCDNS=0; jwplayer.qualityLabel=è¶æ¸; imooc_isnew=2; cvde=58216976274d3-31; jwplayer.volume=80
// Host:t.imooc.com
// Origin:http://t.imooc.com
// Referer:http://t.imooc.com/video/8837
// User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.80 Safari/537.36 Core/1.47.516.400 QQBrowser/9.4.8113.400
// X-Requested-With:XMLHttpRequest
